Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
Mac and OpenDoc are trademarks of Apple Computer, Inc.
Introduction
The OpenDoc TSM Addition is a shared library based on CFM/CFM-68K. It provides a solution to share a single TSM document data structure among all the parts in an OpenDoc document. The input method which supports multi-session, such as Kotoeri, allocates 5 to 10 K byte in the application heap area for every TSM document (TSM session). A text editing part which is embedded in an OpenDoc document/container will be able to reduce application heap by sharing the TSM document.
It contains three functions which replaces or changes the interface types and the refcon field of the TSM document structure. The functions are for sharing a single TSM document, representing a Text Services Manager session, among all the parts in a single OpenDoc document. The library provides a new interface for accessing possibly a TSM Document to be shared.
This library will be installed with OpenDoc-J or a third party product. It means there is no guarantee that the API in the library is always available even if OpenDoc is installed. Therefore, the OpenDoc part needs to import this library as ˙weak import˙ at the object linking process.
Application Program Interfaces
The shared library provides the following three APIs for OpenDoc part.
• ODNewTSMDocumentForPart
The ODNewTSMDocumentForPart function creates a shared TSM document and returns a TSM document ID to be shared. If a single TSM document is being shared, the interface types and refcon of the shared TSM document are replaced and returned. If there is no shared TSM document ID in the document process, it creates a new TSM document with the interface type and refcon using NewTSMDocument and returns its TSM document ID as the shared one. See also the NewTSMDocument function in InsideMacintosh: Text.
Pascal OSErr ODNewTSMDocumentForPart( short interfaceNum, OSType interfaceType[], TSMDocumentID *docID, long refcon)
interfaceNum is the number of text service interface types. Currently, this number must be 1.
interfaceType is a list of text service interface types. This list helps the Text Services Manager to locate the text services that have the correct interface type. Currently, the Text Services Manager has defined one interface type: kTextService ( = 'tsvc'). The caller can also set another interface type: kTSMTEInterfaceType ( = 'tmTE'), if the TSMTE is installed into your Extension folder. The data type interfaceType is a simple array of 4-character (OSType) tags.
docID is a TSM document ID to be shared if the completion of the call is successful.
refCon is a reference constant to store in the TSM document record. It may have any value you wish. If you pass kTSMTEInterfaceType to NewTSMDocument, this argument has a different meaning: Instead of a value to be stored in the TSM document, you should pass in the address of a variable for TSMTERecHandle.
• ODUseTSMDocumentForPart
The ODUseTSMDocumentForPart function changes the interface type of a TSM document in order to activate the sharing of the TSM document on your part. Your part has to call this function just before calling the function which takes the TSM document ID parameter such as ActivateTSMDocument() or ODDeleteTSMDocumentForPart(). The text edit part will have to call this before calling ActivateTSMDocument(), DeactivateTSMDocument(), FixTSMDocument(), or ODDeleteTSMDocumentForPart().
Pascal OSErr ODUseTSMDocumentForPart( short interfaceNum, OSType interfaceType[], TSMDocumentID docID, long refcon)
• ODDeleteTSMDocumentForPart
The ODDeleteTSMDocumentForPart function closes opened text service components for the shared TSM document. If the TSM document is not shared with other parts, it is closed completely.
Also the OpenDoc part always checks to see that the API was successfully unresolved at the load time. The following code illustrates how to check this. The part needs to import this shared libray as ˙weak import˙ to use the following piece.
/* Check the availability of sharing TSM */
Boolean gValidShareTSMLib;
if ((Ptr)ODNewTSMDocumentForPart == (Ptr)nil)
gValidShareTSMLib = false;
else
gValidShareTSMLib = true;
Therefore, OpenDoc parts needs to check the availability of API before calling API.